package gdou.gym.dao;

import gdou.gym.entity.SpaceTime;
import gdou.gym.entity.SpaceTimeExample;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SpaceTimeMapper {
    long countByExample(SpaceTimeExample example);

    int deleteByExample(SpaceTimeExample example);

    int deleteByPrimaryKey(Integer id);

    @Select("select distinct time from space_time")
    List<String> getTime();


    @MapKey("id")
    List<SpaceTime> initRemain();

    int insert(SpaceTime record);


    int cancelOrder(String no, String data, String time);

  /*  @Update("update space_time set remain=remain-1 where id=#{id} ")
    int updateSpaceTimeRemain(Integer id);*/

    @Update("update space_time set remain=#{remain} where id=#{id}")
    int updateSpaceTimeRemain(@Param("id") Integer id,
                               @Param("remain") Integer remain);

    int getIdByDataAndTimeAndNo(String data, String time, String no);

    int insertSelective(SpaceTime record);

    List<SpaceTime> selectByExample(SpaceTimeExample example);

    SpaceTime selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") SpaceTime record, @Param("example") SpaceTimeExample example);

    int updateByExample(@Param("record") SpaceTime record, @Param("example") SpaceTimeExample example);

    int updateByPrimaryKeySelective(SpaceTime record);

    int updateByPrimaryKey(SpaceTime record);
}